JBoss Community Archive (Read Only)

Teiid 8.3

OData Support

What is OData

The Open Data Protocol (OData) is a Web protocol for querying and updating data that provides a way to unlock your data and free it from silos that exist in applications today. OData does this by applying and building upon Web technologies such as HTTP, Atom Publishing Protocol (AtomPub) and JSON to provide access to information from a variety of applications, services, and stores. The protocol emerged from experiences implementing AtomPub clients and servers in a variety of products over the past several years. OData is being used to expose and access information from a variety of sources including, but not limited to, relational databases, file systems, content management systems and traditional Web sites.

OData is consistent with the way the Web works - it makes a deep commitment to URIs for resource identification and commits to an HTTP-based, uniform interface for interacting with those resources (just like the Web). This commitment to core Web principles allows OData to enable a new level of data integration and interoperability across a broad range of clients, servers, services, and tools.

copied from http://odata.org

Teiid Support for OData

When a user successfully deploys a VDB into a Teiid Server, similar JDBC and ODBC protocol support, the OData protocol support is implicitly provided by the Teiid server without any further configuration. OData is support is currently not available in the Teiid Embedded profile. Teiid makes use of JBoss AS and its already configured RestEasy libraries, and OData4J libraries to provide a Rest based access to the VDB. The access would be similar to accessing to any web resources deployed on JBoss AS. OData support is implemented and deployed through WAR file. A user can access this WAR file in <jboss-as>/modules/org/jboss/teiid/deployments/odata-8.3.0.Final.war. This WAR can be configured with following properties in the web.xml file.

Property Name

Description

Default Value

batch-size

Number of rows to send back each time, -1 returns all rows

256

skiptoken-cache-time

Time interval between the results being recycled/expired between $skiptoken requests

300000

local-transport-name

Teiid Local transport name for connection

odata

Teiid OData server, implements cursoring logic when the result rows exceed the configured batch size. On every request, only batch-size number of rows are returned. Each such request is considered an active cursor, with a specified amount of idle time specified by skip-token-cache-time. After the cursor is timed out, the cursor will be closed and remaining results will be cleaned up, and will no longer be available for further queries. Since there is no session based tracking of these cursors, if the request for skiptoken comes after the expired time, the original query will be executed again and tries to reposition the cursor to relative absolute potion, however the results are not guaranteed to be same as the underlying sources may have been updated with new information meanwhile.

Access

For example, if you have a vdb by name northwind deployed and that vdb has a table customers then you can access that table as

http://localhost:8080/odata/northwind.1/customers

this would be akin to, making a JDBC/ODBC connection and issuing a SQL call as

SELECT * FROM customers

the returned results from OData query can be in Atom/AtomPub xml format or JSON format. By default AtomPub based XML result is returned.

User can also submit criteria with their query

http://localhost:8080/odata/northwind.1/customers?$filter=name eq 'bob'

this would be akin to, making a JDBC/ODBC connection and issuing a SQL call as

SELECT * FROM customers where name = 'bob'

The power of OData querying comes from navigations from one entity to another, similar the foreign key relationships in the relational world. For example, if customers table had a association with orders table, where say customers table had primary key of id then, user can issue a query like

http://localhost:8080/odata/northwind.1/customers(1234)/orders?$filter=orderdate > '12-31-2012'

this would be akin to, making a JDBC/ODBC connection and issuing a SQL call as

SELECT * FROM orders o join customers c join o.customer_id = c.id where c.id=1234 and o.orderdate > '12-31-2012'

For detail protocol access you can read the specification at http://odata.org. You can also read this very useful web resource for an example access of a OData server.

Security

Currently by default the OData access is secured using the HTTPBasic, and user will be authenticated against the Teiid's default security domain "teiid-security" and makes use of the security role odata. However, if you wish to change the security domain, manually edit the web.xml file WAR file in <modules>/org/jboss/teiid/main/deployments directory. In future versions more WS-Security based configurations will be provided.

Limitations

The following feature limitations currently apply.

  • Currently the Teiid implements OData V2 specification along with many V3 features, however not completely OData V3 supported.

  • Blob support for media types are currently not supported.

  • "$value" construct to retrieve individual column value is not supported

  • create/update/delete $links is not supported

  • $expand is not supported

Client Tools for Access

OData access is really where the user comes in, depending upon your programming model and needs there are various ways you write your access layer into OData. The following are some suggestions

  • Your Browser: The OData Explorer is an online tool for browsing an OData data service.

  • Microsoft .NET Framework 3.51: the WCF Data Services framework is available as a separate download for .NET 3.x.

  • Microsoft .NET Framework 4.0: the WCF Data Services framework built into .NET 4.0 (in release candidate as of this writing).

  • Silverlight 3: the Data Services client library for Silverlight is available for download.

  • Java: the Restlet 2.0 library for Java (including Java on your Android phone) supports the OData protocol.

  • Java: Use a library like OData4J for Java based access, or any Rest based framework

  • JavaScript: the XMLHttpRequest object is standard in modern browsers or you can use jQuery, which comes out of the box with .NET 4.0 or is available for download.

  • PHP: the Toolkit for PHPprovides OData support for PHP clients.

  • AJAX: if you're using AJAX for ASP.NET, Microsoft provides the ASP.NET Ajax Library for getting to OData.

  • Excel 2010 PowerPivot: PowerPivot comes with OData support built right in.

  • Windows Desktop: LINQPad is a wonderful tool for building OData queries interactively.

  • Shell Scripts: use CURL tool

How Teiid exposes schema for OData

OData defines its schema using Conceptual Schema Definition Language (CSDL). Every VDB, that is deployed in an ACTIVE state in Teiid server exposes its metadata in CSDL format. For example if you want retrieve metadata for your vdb northwind, you need to issue a query like

http://localhost:8080/odata/northwind/$metadata

Since OData schema model is not a relational schema model, Teiid uses the following semantics to map its relational schema model to OData schema model.

Relational Entity

Mapped OData Entity

Model Name

Schema Namespace, EntityContainer Name

Table/View

EntityType, EntitySet

Table Columns

EntityType's Properties

Primary Key

EntityType's Key Properties

Foreign Key

Navigation Property on EntityType, Association, AssosiationSet

Procedure

FunctionImport

Procedure's Table Return

ComplexType

Teiid by design does not define any "embedeed" ComplexType in the EnitityType

Teiid does not define any one EntityContainer that resulted from different vdb models as a default container, so all entities must be accessed using full path to them.

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-13 12:37:51 UTC, last content change 2013-03-14 16:27:06 UTC.